import {request,mockreq} from '@/utils/http/index'

//三级列表数据请求
export const getThreeListRequest = () =>{
    return request.get("/api/product/getBaseCategoryList")
};

//请求banner图片
export const getMockReq = () => {
    return mockreq.get("/banner")
}

//请求floor的数据
export const getMockFloorReq = () => {
    return mockreq.get("/floor")
}

//请求搜索页数据
export const getSearchPageRequest = (params) => {
    return request.post("/api/list",params)
}

//请求详情页数据
export const getDetailRequest = (params) => {
    return request.get(`/api/item/${params}`)
} 

//加入购物车 或者 修改购物车某个商品的数量 请求 
export const getAddCartRequest = ({skuId, skuNum }) => {
    return request.post(`/api/cart/addToCart/${skuId}/${skuNum}`)
}

//购物车列表请求
export const getShopCartRequest = () => {
    return request.get("/api/cart/cartList")
}

//修改单个商品的选中状态
export const getUpdateSingleCheckedRequest = ({ skuId, isChecked }) => {
    return request.get(`/api/cart/checkCart/${skuId}/${isChecked}`);
};

//修改所有购物车商品的选中状态
export const getUpdateAllCheckedRequest = (isChecked, skuIdList) => {
    return request.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList);
};

//删除购物车单个商品
export const getDeleteSingleGoodRequest= (skuId) => {
    return request.delete(`/api/cart/deleteCart/${skuId}`);
};

//删除所有的购物车商品
export const getDeleteAllGoodsRequest = (skuIdList) => {
    return request.delete(`/api/cart/batchDeleteCart`, {
      data: skuIdList,
    });
};

//获取验证码请求
export const getCodeRequest = (phone) => {
    return request.get(`/api/user/passport/sendCode/${phone}`)
}

//完成注册请求
export const getRegisterRequest = (registerInfo) => {
    return request.post(`/api/user/passport/register`, registerInfo)
}

//登入请求
export const getLoginRequest = (userInfo) => {
    return request.post(`/api/user/passport/login`, userInfo);
};

//登录以后获取用户信息
export const getUserInfoRequest = () => {
    return request.get("/api/user/passport/auth/getUserInfo");
};

//退出登录
export const getLogoutRequest = () => {
    return request.get("/api/user/passport/logout");
};

//交易页数据获取
export const getTradeInfoRequest = () => {
    return request.get("/api/order/auth/trade");
};

//请求购物地址
export const getTradeAddressRequest = () => {
    return mockreq.get("/address");
};

//提交订单
export const getAddTrade = (tradeNo, tradeInfo) => {
    return request.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}`,tradeInfo);
};

//获取支付详情
export const getPayDetailRequest = (orderId) => {
    return request.get(`/api/payment/weixin/createNative/${orderId}`)
}

//查看某个订单编号的支付状态
export const getPayStatusRequest = (orderId) => {
    return request.get(`/api/payment/weixin/queryPayStatus/${orderId}`);
};

//获取订单页详情
export const getOrderDetailRequest = ({page,limit}) => {
    return request.get(`/api/order/auth/${page}/${limit}`)
}